package com.content.view.Frame.MainPanel.MPHome
{
	import com.content.model.OnlineRes.OnlineResHomeVO;
	import com.library.core.IDisposable;
	import com.library.core.UIObject;
	
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	
	public class RecommendItem extends UIObject implements IDisposable
	{
		public static const WIDTH:int = 76+6;
		public static const HEIGHT:int = 100+6;
		
		
		private var _bg:Shape;
		private var _vo:OnlineResHomeVO;
		private var _coverLoader:Loader;
		
		public function RecommendItem(vo:OnlineResHomeVO)
		{
			super();
			
			mouseChildren = false;
			buttonMode = true;
			
			_vo = vo;
			
			_bg = new Shape();
			addChild(_bg);
			
			_bg.graphics.beginFill(0xffffff, 1.0);
			_bg.graphics.drawRect(0,0,WIDTH, HEIGHT);
			
			_coverLoader = new Loader();
			addChild(_coverLoader);
			_coverLoader.x = 3;
			_coverLoader.y = 3;
			
			_coverLoader.load( new URLRequest(vo.CoverURL) );
			
			this.addEventListener(MouseEvent.MOUSE_OVER, OnOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, OnOut);
		}
		
		public function get VO():OnlineResHomeVO{	return _vo;	}
		
		/* Event Handler
		 * ---------------------------------------------------------- */
		private function OnOver(evt:MouseEvent):void{
			_bg.graphics.clear();
			_bg.graphics.beginFill(0x3c6995, 1);
			_bg.graphics.drawRect(0,0,WIDTH, HEIGHT);
		}
		
		private function OnOut(evt:MouseEvent):void{
			_bg.graphics.clear();
			_bg.graphics.beginFill(0xffffff, 1);
			_bg.graphics.drawRect(0,0,WIDTH, HEIGHT);
		}
		
		public function Dispose():void
		{
			this.removeEventListener(MouseEvent.MOUSE_OVER, OnOver);
			this.removeEventListener(MouseEvent.MOUSE_OUT, OnOut);
		}
	}
}